<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <input id="year" type="text">
  <button id="btn">判断</button>
  <input id="result" type="text">
  <script>
    var yearInp = document.querySelector(' #year');
    var btn = document.querySelector(' #btn');
    var resultInp = document.querySelector(' #result');
    console.log(yearInp, btn, resultInp);
    btn.onclick = function () {
      var year = yearInp.value;
      if (year >= 1000 && year <= 9999 && year % 1 == 0) {
        console.log('year Ok!');
        if (year % 100 != 0 && year % 4 == 0 || year % 400 == 0) {
          // document.write(year + '为闰年');
          console.log(year + '为闰年');
          // resultInp.value = year;
          resultInp.value = year + '为闰年';
        } else {
          // document.write(year + '为平年');
          console.log(year + '为平年');
          resultInp.value = year + '为平年';
        }
      }
    }


  </script>
</body>

</html>